﻿//规则属性
var ruleProperty = {

    RuleProperty: {
        ruleName: {
            'title': "规则名称：",
            'control': $("<textarea id='RuleName'>")
        },
        CONDITION: {
            'title': "表达式：",
            'control': $("<textarea id='RuleCondition'>")
        }
    },
    //初始化页面
    InitialPage: function (rule) {
        debugger;
        var me = this;
        me.rule = rule;
        me.InitialControl();
        me.InitialData(rule);
    },
    //初始化数据
    InitialData: function (rule) {
        var me = this;
        if (rule.RuleProperty != undefined) {
            me.RuleProperty.ruleName.control.val(rule.RuleProperty.ruleName);
            me.RuleProperty.CONDITION.control.val(rule.RuleProperty.condition);
        }
    },

    InitialControl: function () {
        $("#divRulePropertyContainer").empty();
        var me = this;
        var container = $("<div>");
        divName = $("<div class='Long'>");
        divName.html(me.RuleProperty.ruleName.title);
        divName.append(me.RuleProperty.ruleName.control);
        divCondition = $("<div class='Long'>");
        divCondition.html(me.RuleProperty.CONDITION.title);
        divCondition.append(me.RuleProperty.CONDITION.control);

        container.append(divName);
        container.append(divCondition);
        $("#divRulePropertyContainer").append(container);
    },
    //保存数据
    SaveData: function (rule) {
        var me = this;
        if (rule.RuleProperty == undefined) {
            rule.RuleProperty = {};
        }
        rule.RuleProperty.ruleName = me.RuleProperty.ruleName.control.val();
        rule.RuleProperty.expression = me.RuleProperty.CONDITION.control.val();

        ToolBar.HistroyOpertion();
    }
}